package cn.huiyunche.admin.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.huiyunche.base.service.interfaces.CWaybillTrailService;
import cn.huiyunche.base.service.model.CWaybillTrail;
import cn.huiyunche.base.service.vo.Result;

@RequestMapping("/waybilltrail")
@Controller
public class CWaybillTrailController {
	@Autowired
	private CWaybillTrailService cWaybillTrailService = null;

	/**
	 * 上报在途信息
	 * 
	 * @param cWaybillTrail
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/add", method = RequestMethod.POST)
	@ResponseBody
	public Result<Object> add(CWaybillTrail cWaybillTrail) throws Exception {
		Result<Object> result = new Result<Object>(true, null, "数据加载成功");
		result.setData(this.getCWaybillTrailService().add(cWaybillTrail));
		return result;
	}

	/**
	 * 根据运单ID查询运单物流信息
	 * 
	 * @param waybillId
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/selectbywaybillid", method = RequestMethod.GET)
	@ResponseBody
	public Result<List<CWaybillTrail>> list(Long waybillId) throws Exception {
		Result<List<CWaybillTrail>> result = new Result<List<CWaybillTrail>>(true, null, "物流信息加载成功");
		result.setData(this.getCWaybillTrailService().selectByWaybillId(waybillId));
		return result;
	}

	private CWaybillTrailService getCWaybillTrailService() {
		return this.cWaybillTrailService;
	}
}
